/*
@file	LineSegment.h
@author	Saume
*/

#ifndef LINESEGMENT_H
#define LINESEGMENT_H

#include "Vector.h"

// amount to extend the lines to check if they point toward a given other line segment
#define EXTEND 1024.0f

class LineSegment;
class Circle;
bool operator==(const LineSegment&, const LineSegment&);

class LineSegment {
private: 
	Vector* from;
	Vector* to;
	Vector* normal;
	Vector* normalNeg;
	void CalculateNormals();
public: 
	LineSegment();
	LineSegment(float, float, float, float);
	LineSegment(const Vector* const, const Vector* const);
	~LineSegment();
	float CalculateSlope() const;
	float CalculateIntercept() const;
	bool IsVerticalLine() const;
	Vector* GetFrom() const { return from; }
	Vector* GetTo() const { return to; }
	Vector* GetNormal() const { return normal; }
	Vector* GetNormalNeg() const { return normalNeg; }
	Vector* CollisionPoint(const LineSegment* const) const;
	bool IntersectsWith(const LineSegment* const) const;
	bool IntersectsWith(const Circle* const) const;
	float CalculateDiscriminant(float, float, float) const;
	bool PointIsInSegment(float, float) const;
	LineSegment* Extend(float) const;
	void Display() const;
};

#endif